package com.code.zjm.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by ZJM on 2017/4/27.
 * 数据库创建与版本管理协助类
 */
public class MyDBHelper extends SQLiteOpenHelper {

    public MyDBHelper(Context context, String name, int version) {
        super(context, name, null, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        StringBuffer tableCreate = new StringBuffer();
        tableCreate.append("create table ")
                .append(DBHelper.TABLE_NAME)
                .append(" (")
                .append("_id integer primary key autoincrement,")
                .append("name text,")
                .append("mobile_phone text,")
                .append("office_phone text,")
                .append("family_phone text,")
                .append("address text,")
                .append("other_contact text,")
                .append("email text,")
                .append("position text,")
                .append("company text,")
                .append("zip_code text,")
                .append("remark text,")
                .append("image_id int,")
                .append("privacy int ")
                .append(")");
        System.out.println(tableCreate.toString());
        db.execSQL(tableCreate.toString());
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}